'use strict';

const Service = require('egg').Service;

class TypeService extends Service {
  //获取购房类型
  async getType() {
    const type = await this.app.mysql.query("SELECT * from house_type");

    return type
  }
  async getHouseList(house_name, type_id) {
    console.log(house_name)
    try{
      const type = await this.app.mysql.query(`SELECT l.* from house_type as t RIGHT JOIN houselist as l ON t.type_id = l.type_id WHERE house_name LIKE '%${house_name}%' AND l.type_id = ${type_id} ORDER BY create_date ASC`);
      return type
    }catch(err){
      // return {}
    }
  }
}

module.exports = TypeService;
